<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of registro
 *
 * @author Neil
 */
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Registro extends CI_Controller {
    
    public function infoRegistro($reg) {
        $this->load->model("registro_model");
        $data["registros"] = $this->registro_model->listRegistros($reg,"","");
        echo json_encode($data);
    }

    public function detalleMontoRegistro($reg) {
        $this->load->model("registro_model");
        $data["registros"] = $this->registro_model->detalleMonto($reg);

        echo json_encode($data);
    }

    public function registrarDetalleMonto($registro) {
        $data = json_decode($_POST['detalleMonto']);

        foreach ($data as $fila) {
            $datos[] = array(
                'registro' => $fila->registro,
                'submonto' => $fila->submonto
            );
        }

        $dataMon = array(
            'monto' => $_POST["monto"]
        );

        $this->load->model('registro_model');
        try {
            $this->registro_model->regDetalleMonto($registro, $datos, $dataMon);
            $valor = TRUE;
        } catch (Exception $exc) {
            $valor = FALSE;
        }

        echo json_encode($valor);
    }

    public function login() {
        $this->load->view('login');
    }

    public function sesion() {
        $data['nom'] = $this->session->userdata['nombre'];
        $data['ape'] = $this->session->userdata['apellido'];
        $data['ruta'] = "";
        $data['css'] = array('inicio' => '', 'mantenedor' => '', 'reserva' => 'active open');
        $this->load->view('estructura/head', $data);
    }

}

?>
